<?php

namespace Gairal\CoreBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;

/**
 * Skill
 *
 * @ORM\Table(name="gairal_skill")
 * @ORM\Entity(repositoryClass="Gairal\CoreBundle\Entity\SkillRepository")
 * @UniqueEntity(fields="name", message="This category already exists in the database.")
 */
class Skill
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="name", type="string", length=50, unique=true)
     * @Assert\NotBlank()
     * @Assert\Length(min="3")
     */
    private $name;

    /**
     * @var string
     *
     * @ORM\Column(name="description", type="string", length=255, nullable=true)
     * @Assert\Length(min="3")
     */
    private $description;

    /**
     * @var integer
     *
     * @ORM\Column(name="level", type="smallint", nullable=true)
     * @Assert\Range(min=0, max=100)
     */
    private $level;

    /**
     * @var string
     *
     * @ORM\ManyToOne(targetEntity="Gairal\CoreBundle\Entity\Category", inversedBy="skills")
     * @ORM\JoinColumn(nullable=false)
     */
    private $category;

    /**
     * @ORM\ManyToMany(targetEntity="Gairal\CoreBundle\Entity\Education", mappedBy="skills")
     * @ORM\JoinColumn(nullable=true)
     */
    private $educations;

    /**
     * @ORM\ManyToMany(targetEntity="Gairal\CoreBundle\Entity\Experience", mappedBy="skills")
     * @ORM\JoinColumn(nullable=true)
     */
    private $experiences;


    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set name
     *
     * @param string $name
     * @return Skill
     */
    public function setName($name)
    {
        $this->name = $name;
    
        return $this;
    }

    /**
     * Get name
     *
     * @return string 
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Set description
     *
     * @param string $description
     * @return Skill
     */
    public function setDescription($description)
    {
        $this->description = $description;
    
        return $this;
    }

    /**
     * Get description
     *
     * @return string 
     */
    public function getDescription()
    {
        return $this->description;
    }

    /**
     * Set level
     *
     * @param integer $level
     * @return Skill
     */
    public function setLevel($level)
    {
        $this->level = $level;
    
        return $this;
    }

    /**
     * Get level
     *
     * @return integer 
     */
    public function getLevel()
    {
        return $this->level;
    }

    /**
     * Set category
     *
     * @param \Gairal\CoreBundle\Entity\Category $category
     * @return Skill
     */
    public function setCategory(\Gairal\CoreBundle\Entity\Category $category = null)
    {
        $this->category = $category;
    
        return $this;
    }

    /**
     * Get category
     *
     * @return \Gairal\CoreBundle\Entity\Category 
     */
    public function getCategory()
    {
        return $this->category;
    }
    /**
     * Constructor
     */
    public function __construct()
    {
        $this->educations = new \Doctrine\Common\Collections\ArrayCollection();
        $this->experiences = new \Doctrine\Common\Collections\ArrayCollection();
    }
    
    /**
     * Add educations
     *
     * @param \Gairal\CoreBundle\Entity\Education $educations
     * @return Skill
     */
    public function addEducation(\Gairal\CoreBundle\Entity\Education $educations)
    {
        $this->educations[] = $educations;
    
        return $this;
    }

    /**
     * Remove educations
     *
     * @param \Gairal\CoreBundle\Entity\Education $educations
     */
    public function removeEducation(\Gairal\CoreBundle\Entity\Education $educations)
    {
        $this->educations->removeElement($educations);
    }

    /**
     * Get educations
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getEducations()
    {
        return $this->educations;
    }

    /**
     * Add experiences
     *
     * @param \Gairal\CoreBundle\Entity\Experience $experiences
     * @return Skill
     */
    public function addExperience(\Gairal\CoreBundle\Entity\Experience $experiences)
    {
        $this->experiences[] = $experiences;
    
        return $this;
    }

    /**
     * Remove experiences
     *
     * @param \Gairal\CoreBundle\Entity\Experience $experiences
     */
    public function removeExperience(\Gairal\CoreBundle\Entity\Experience $experiences)
    {
        $this->experiences->removeElement($experiences);
    }

    /**
     * Get experiences
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getExperiences()
    {
        return $this->experiences;
    }
}